from django.urls import path

from . import views

app_name = 'battles'

urlpatterns = [
    # 世界杯相关
    path('worldcup/', views.worldcup_list, name='worldcup_list'),
    path('worldcup/create/', views.admin_worldcup_create, name='admin_worldcup_create'),
    path('worldcup/<int:worldcup_id>/delete/', views.admin_worldcup_delete, name='admin_worldcup_delete'),
    path('worldcup/<int:worldcup_id>/', views.worldcup_detail, name='worldcup_detail'),
    path('worldcup/<int:worldcup_id>/regular-season/', views.worldcup_regular_season, name='worldcup_regular_season'),
    path('worldcup/<int:worldcup_id>/battles/', views.worldcup_battles, name='worldcup_battles'),
    path('worldcup/<int:worldcup_id>/championship/', views.worldcup_championship, name='worldcup_championship'),
    path('worldcup/<int:worldcup_id>/special-rankings/', views.worldcup_special_rankings, name='worldcup_special_rankings'),
    path('api/worldcup/<int:worldcup_id>/', views.api_worldcup_detail, name='api_worldcup_detail'),
    path('api/worldcup/<int:worldcup_id>/regular-season-data/', views.api_worldcup_regular_season_data, name='api_worldcup_regular_season_data'),
    path('api/worldcup/<int:worldcup_id>/championship-data/', views.api_worldcup_championship_data, name='api_worldcup_championship_data'),
    path('api/worldcup/<int:worldcup_id>/stage-transition-status/', views.api_worldcup_stage_transition_status, name='api_worldcup_stage_transition_status'),
    path('api/worldcup/<int:worldcup_id>/status/', views.api_worldcup_status, name='api_worldcup_status'),
    path('api/worldcup/<int:worldcup_id>/ongoing-battles/', views.api_worldcup_ongoing_battles, name='api_worldcup_ongoing_battles'),
    # Admin专用 世界杯常规赛管理
    path('api/admin/worldcup/<int:worldcup_id>/confirm-participants/', views.admin_worldcup_confirm_participants, name='admin_worldcup_confirm_participants'),
    path('api/admin/worldcup/<int:worldcup_id>/start-regular-season/', views.admin_worldcup_start_regular_season, name='admin_worldcup_start_regular_season'),
    path('api/admin/worldcup/<int:worldcup_id>/start-championship/', views.admin_worldcup_start_championship, name='admin_worldcup_start_championship'),
    path('api/admin/worldcup/<int:worldcup_id>/start-round16-grouping/', views.admin_worldcup_start_round16_grouping, name='admin_worldcup_start_round16_grouping'),
    path('api/admin/worldcup/<int:worldcup_id>/check-progress/', views.admin_worldcup_check_progress, name='admin_worldcup_check_progress'),
    path('api/admin/worldcup/<int:worldcup_id>/force-end-regular-season/', views.admin_worldcup_force_end_regular_season, name='admin_worldcup_force_end_regular_season'),
    path('api/admin/worldcup/<int:worldcup_id>/available-users/', views.admin_worldcup_available_users, name='admin_worldcup_available_users'),
    path('api/admin/worldcup/<int:worldcup_id>/manual-select-participants/', views.admin_worldcup_manual_select_participants, name='admin_worldcup_manual_select_participants'),
    path('api/admin/worldcup/<int:worldcup_id>/remove-participant/<int:participant_id>/', views.admin_worldcup_remove_participant, name='admin_worldcup_remove_participant'),
    path('api/admin/worldcup/<int:worldcup_id>/requeue-error-pending-battles/', views.admin_worldcup_requeue_error_pending_battles, name='admin_worldcup_requeue_error_pending_battles'),
    path('api/admin/worldcup/<int:worldcup_id>/requeue-championship-error-pending-battles/', views.admin_worldcup_requeue_championship_error_pending_battles, name='admin_worldcup_requeue_championship_error_pending_battles'),
    path('api/admin/worldcup/<int:worldcup_id>/auto-requeue-battles/', views.api_worldcup_auto_requeue_battles, name='api_worldcup_auto_requeue_battles'),
    # Admin专用 世界杯战斗队列管理
    path('api/admin/worldcup/<int:worldcup_id>/battle-queue-status/', views.api_worldcup_battle_queue_status, name='api_worldcup_battle_queue_status'),
    path('api/admin/worldcup/<int:worldcup_id>/restart-battle-queue/', views.api_worldcup_restart_battle_queue, name='api_worldcup_restart_battle_queue'),
    path('api/admin/worldcup/<int:worldcup_id>/stop-battle-queue/', views.api_worldcup_stop_battle_queue, name='api_worldcup_stop_battle_queue'),
   # Admin专用 世界杯冠军赛管理
    path('api/admin/worldcup/<int:worldcup_id>/check-championship-progress/', views.admin_worldcup_check_progress, name='admin_worldcup_check_championship_progress'),
    path('api/admin/worldcup/<int:worldcup_id>/championship-queue-status/', views.api_worldcup_championship_queue_status, name='api_worldcup_championship_queue_status'),
    path('api/admin/worldcup/<int:worldcup_id>/start-championship-queue/', views.admin_worldcup_start_championship_queue, name='admin_worldcup_start_championship_queue'),
    path('api/admin/worldcup/<int:worldcup_id>/restart-championship-queue/', views.api_worldcup_restart_battle_queue, name='api_worldcup_restart_championship_queue'),
    path('api/admin/worldcup/<int:worldcup_id>/stop-championship-queue/', views.api_worldcup_stop_battle_queue, name='api_worldcup_stop_championship_queue'),
    path('api/admin/worldcup/<int:worldcup_id>/rerun-error-battles/', views.admin_worldcup_rerun_error_battles, name='admin_worldcup_rerun_error_battles'),
    path('api/admin/worldcup/<int:worldcup_id>/rerun-championship-error-battles/', views.admin_worldcup_rerun_championship_error_battles, name='admin_worldcup_rerun_championship_error_battles'),
    path('api/admin/worldcup/<int:worldcup_id>/advance-next-stage/', views.admin_worldcup_advance_next_stage, name='admin_worldcup_advance_next_stage'),
    # 对战列表和详情
    path('', views.battle_list, name='battle_list'),
    path('<int:battle_id>/', views.battle_detail, name='battle_detail'),
    path('<int:battle_id>/error/', views.battle_error, name='battle_error'),
    path('history/', views.battles_history, name='battles_history'),

    # 对战创建和管理
    path('create/', views.battle_create, name='battle_create'),
    # 对战统计
    path('statistics/', views.battle_statistics, name='battle_statistics'),
    path('ranking/', views.battle_ranking, name='battle_ranking'),
    # API接口
    path('api/create/', views.api_battle_create, name='api_battle_create'),
    path('api/<int:battle_id>/status/', views.api_battle_status, name='api_battle_status'),

    path('<int:battle_id>/round-progress/', views.api_battle_round_progress, name='api_battle_round_progress'),
    # 代码执行和调试
    path('code/execute/', views.code_execute, name='code_execute'),
    # path('api/code/execute/', views.api_code_execute, name='api_code_execute'),
    # 匹配相关
    path('match/status/', views.match_status, name='match_status'),
    path('match/cancel/', views.cancel_match, name='cancel_match'),

    path('api/match/status/', views.api_match_status, name='api_match_status'),
    path('api/manual-battle-queue/status/', views.api_manual_battle_queue_status, name='api_manual_battle_queue_status'),
    path('api/code/languages/', views.api_supported_languages, name='api_supported_languages'),
    # 战斗命令验证和iframe页面
    path('api/command/validate/', views.api_command_validate, name='api_command_validate'),
    path('<int:battle_id>/iframe/', views.battle_iframe, name='battle_iframe'),
    path('<int:battle_id>/ping/', views.battle_ping, name='battle_ping'),
    # Node.js 战斗服务器管理 API
    path('api/node/create/', views.create_node_battle_server, name='create_node_battle_server'),
    path('api/node/stop/', views.stop_node_battle_server, name='stop_node_battle_server'),
    path('api/node/status/<str:battle_id>/', views.get_node_battle_server_status, name='get_node_battle_server_status'),
    path('api/node/list/', views.list_node_battle_servers, name='list_node_battle_servers'),
    path('api/node/cleanup/', views.cleanup_node_battle_servers, name='cleanup_node_battle_servers'),
    # 执行统计和日志相关API
    path('api/<int:battle_id>/execution-stats/', views.api_battle_execution_stats, name='api_battle_execution_stats'),
    path('api/<int:battle_id>/battle-stats/', views.api_battle_stats, name='api_battle_stats'),
    path('api/<int:battle_id>/debug-log-download/', views.api_battle_debug_log_download, name='api_battle_debug_log_download'),
    path(
        'api/<int:battle_id>/server-log-download/', views.api_battle_server_log_download, name='api_battle_server_log_download'
    ),
    path('api/<int:battle_id>/report-download/', views.api_battle_report_download, name='api_battle_report_download'),
    path('api/<int:battle_id>/rounds/', views.api_battle_rounds, name='api_battle_rounds'),
    path('api/user/execution-logs/', views.api_user_execution_logs, name='api_user_execution_logs'),
    # 用户统计API
    path('api/user/detailed-stats/', views.api_user_detailed_stats, name='api_user_detailed_stats'),
    # 监控仪表板
    path('monitoring/', views.monitoring_dashboard, name='monitoring_dashboard'),
    path('api/monitoring/metrics/', views.api_monitoring_metrics, name='api_monitoring_metrics'),
    path('api/monitoring/alerts/', views.api_monitoring_alerts, name='api_monitoring_alerts'),
    path('api/monitoring/clear-alerts/', views.api_monitoring_clear_alerts, name='api_monitoring_clear_alerts'),
    path('api/monitoring/generate-test-alerts/', views.api_monitoring_generate_test_alerts, name='api_monitoring_generate_test_alerts'),

    # 管理员战斗操作API
    path('api/admin/<int:battle_id>/delete/', views.admin_battle_delete, name='admin_battle_delete'),
    path('api/admin/<int:battle_id>/mark-exciting/', views.admin_battle_mark_exciting, name='admin_battle_mark_exciting'),
    path('api/admin/<int:battle_id>/unmark-exciting/', views.admin_battle_unmark_exciting, name='admin_battle_unmark_exciting'),
    path('api/admin/batch-operation/', views.admin_battle_batch_operation, name='admin_battle_batch_operation'),
]
